﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using SampleImageGenerator.Properties;
using SampleImageGenerator.Core;

namespace SampleImageGenerator.Controls
{
	internal partial class SampleImageForm : Form
	{
		private IEngine m_engine; 

		public SampleImageForm()
		{
			InitializeComponent();

			this.Icon = Resources.SampleImageGeneratorIcon;

			Engine = new EmptyEngine();
		}

		public IEngine Engine
		{
			get
			{
				return m_engine;
			}

			set
			{
				IEngine engine = value; 
				m_engine = engine;
				imageDisplay.Engine = engine;
				console.Engine = engine;
				batchModeGui.Engine = engine;
				engineProgressBar.Engine = engine;
				engine.ErrorOccurred += ErrorOccurredHandler;
			}
		}

		void ErrorOccurredHandler(object sender, ErrorEventArgs e)
		{
			Exception ex = e.GetException();
			MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}

		private void lblAbout_Click(object sender, EventArgs e)
		{
			AboutBox aboutBox = new AboutBox();
			aboutBox.ShowDialog();
		}
	}
}
